import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
// 把这段代码直接粘贴到router/index.js中的Vue.use(VueRouter)之前
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location) {
    return originalPush.call(this, location).catch(err => {})
};

Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: "/home"
    },
    {
        path: '/home',
        name: 'Home',
        component: Home
    },
    // {
    //     path: '/about',
    //     name: 'About',

    //     component: () =>
    //         import ( /* webpackChunkName: "about" */ '../views/About.vue')
    // }
    {
        path: '/goods',
        name: 'Goods',

        component: () =>
            import ( /* webpackChunkName: "goods" */ '../views/Goods.vue')
    }, {
        path: '/user',
        name: 'User',

        component: () =>
            import ( /* webpackChunkName: "user" */ '../views/User.vue')
    }, {
        path: '/order',
        name: 'Order',

        component: () =>
            import ( /* webpackChunkName: "order" */ '../views/Order.vue')
    }, {
        path: '/free',
        name: 'Free',

        component: () =>
            import ( /* webpackChunkName: "free" */ '../views/Free.vue')
    }, , {
        path: '/details',
        name: 'Details',

        component: () =>
            import ( /* webpackChunkName: "details" */ '../views/Details.vue')
    },
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router